package com.student.demo.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        boolean result = false;
        try {
            result = (boolean)request.getSession().getAttribute("pass");
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (result) {
            return true; // 放行
        }
        return false; // 拦截
    }
}


